<template>
  <div class="dashboard-container">
    <div class="dashboard-text">
      <div>
        <el-card>
          <el-row type="flex" justify="end">
            <el-col :span="22">
              <span style="font-size: 12px;color: pink;">说明：目前支持学科和关键字条件筛选</span>
            </el-col>
            <el-col :span="2">
              <el-button
                type="success"
                size="small"
                icon="el-icon-edit"
                @click="$router.push(`/questions/new`)"
              >新增试题</el-button>
            </el-col>
          </el-row>
          <el-form style="margin-top:20px;" label-width="80px" :model="formData">
            <el-row :gutter="20">
              <el-col :span="6">
                <el-form-item label="学科" prop="subjectID">
                  <el-select v-model="formData.subjectID" placeholder="请选择" @change="selectChange">
                    <el-option
                      v-for="item in lists"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="二级目录">
                  <el-select
                    v-model="formData.twoLevelDirectory"
                    placeholder="请选择"
                    style="width:180px"
                  >
                    <el-option
                      v-for="item in directListTwo"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="标签">
                  <el-select v-model="formData.tags" placeholder="请选择">
                    <el-option
                      v-for="item in listsTwo"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="关键字" prop="keyword">
                  <el-input v-model="formData.keyword" style="width:180px"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="6">
                <el-form-item label="试题类型">
                  <el-select v-model="QuestionType" placeholder="请选择" style="width:180px">
                    <el-option label="单选" value="1"/>
                    <el-option label="多选" value="2"/>
                    <el-option label="简答" value="3"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="难度">
                  <el-select v-model="Difficulty" placeholder="请选择">
                    <el-option label="简单" value="1"></el-option>
                    <el-option label="一般" value="2"></el-option>
                    <el-option label="困难" value="3"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="方向">
                  <el-select v-model="Direction" placeholder="请选择">
                    <el-option label="互联网" value="1"></el-option>
                    <el-option label="电子商务" value="0"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="录入人">
                  <el-select v-model="creatorID" placeholder="请选择">
                    <el-option label="超级管理员" value="1"></el-option>
                    <el-option label="录入管理员" value="0"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="6">
                <el-form-item label="题目备注">
                  <el-input v-model="Remarks" style="width:180px"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="企业简称">
                  <el-input v-model="ShortName" style="width:180px"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="城市">
                  <el-select
                    v-model="Province"
                    style="width: 50%;"
                    placeholder="请选择活动区域"
                    @change="renderCity"
                  >
                    <el-option
                      v-for="(item, index) in provinceAll"
                      :key="index"
                      :label="item"
                      :value="item"
                    ></el-option>
                  </el-select>

                  <el-select v-model="City" style="width: 50%;" placeholder="请选择活动区域">
                    <el-option
                      v-for="(item, index) in cityAll"
                      :key="index"
                      :label="item"
                      :value="item"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-row type="flex" justify="center">
                  <el-col :offset="6">
                    <el-button size="small" @click="clearAll()">清除</el-button>
                    <el-button type="primary" size="small" @click="newlist()">搜索</el-button>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
          </el-form>
          <!-- 标签页 -->
          <el-row>
            <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
              <el-tab-pane label="全部" name="first">
                <!-- 全部开始 -->
                <el-row>
                  <template #default>
                    <el-alert
                      slot="before"
                      type="info"
                      show-icon
                      :closable="false"
                      style="line-height:10px"
                    >数据一共{{ total }}条</el-alert>
                  </template>
                </el-row>
                <el-table :data="list" style="width: 100%" height="250">
                  <el-table-column prop="number" label="试题编号" width="150"></el-table-column>
                  <el-table-column prop="subject" label="学科" width="120"></el-table-column>
                  <el-table-column prop="catalog" label="目录" width="120"></el-table-column>
                  <el-table-column prop="questionType" label="题型" width="120">
                    <template slot-scope="scope">
                      <span v-if="scope.row.difficulty === '1'">单选</span>
                      <span v-else-if="scope.row.difficulty === '2'">多选</span>
                      <span v-else>简答</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="question" label="题干" width="300">
                    <template v-slot="{row}">
                      <span v-html="row.question"></span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="addDate" label="录入时间" width="120">
                    <template slot-scope="obj">{{ obj.row.addDate | formatDate }}</template>
                  </el-table-column>
                  <el-table-column prop="difficulty" label="难度">
                    <template slot-scope="scope">
                      <span v-if="scope.row.difficulty === '1'">一般</span>
                      <span v-else-if="scope.row.difficulty === '2'">简单</span>
                      <span v-else>困难</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="creator" label="录入人" width="120"></el-table-column>
                  <el-table-column prop="chkState" label="审核状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.chkState === 1">已通过</span>
                      <span v-else-if="scope.row.chkState === 2">已拒绝</span>
                      <span v-else>待审核</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="chkRemarks" label="审核意见" width="120"></el-table-column>
                  <el-table-column prop="chkUser" label="审核人"></el-table-column>
                  <el-table-column prop="publishState" label="发布状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.publishState === 1">已发布</span>
                      <span v-else-if="scope.row.publishState === 0">已下架</span>
                      <span v-else>待发布</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="right" label="操作" fixed="right" width="220">
                    <template #default="{row}">
                      <el-button type="text" size="samll" @click="seeChoice(row.id)">预览</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.chkState === 1"
                        @click="CheckChkState(row)"
                      >审核</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.publishState === 1"
                        @click="$router.push(`/questions/new/${row.id}`)"
                      >修改</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        @click="open(row.id,row.publishState)"
                      >{{ row.publishState === 1? '下架':'上架' }}</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.publishState === 1"
                        @click="delopen(row.id)"
                      >删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
                <!-- 分页 -->
                <el-row type="flex" justify="end" class="pagination">
                  <!-- page-size每页显示条目个数 -->
                  <!-- current-page当前页码  @current-change监听分页-->
                  <el-pagination
                    background
                    :page-size="page.pagesize"
                    :page-sizes="[5, 10, 15]"
                    :current-page="page.page"
                    layout="prev, pager, next,sizes, jumper"
                    :total="total"
                    @current-change="pageChange"
                    @size-change="handleSizeChange"
                  />
                </el-row>
                <!-- 全部结束 -->
              </el-tab-pane>
              <el-tab-pane label="待审核" name="second">
                <!-- 待审核开始 -->
                <el-row>
                  <template #default>
                    <el-alert slot="before" type="info" show-icon :closable="false">数据一共{{ total }}条</el-alert>
                  </template>
                </el-row>
                <el-table :data="list" style="width: 100%" height="250">
                  <el-table-column prop="number" label="试题编号" width="150"></el-table-column>
                  <el-table-column prop="subject" label="学科" width="120"></el-table-column>
                  <el-table-column prop="catalog" label="目录" width="120"></el-table-column>
                  <el-table-column prop="questionType" label="题型" width="120">
                    <template slot-scope="scope">
                      <span v-if="scope.row.difficulty === '1'">单选</span>
                      <span v-else-if="scope.row.difficulty === '2'">多选</span>
                      <span v-else>简答</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="question" label="题干" width="300">
                    <template v-slot="{row}">
                      <span v-html="row.question"></span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="addDate" label="录入时间" width="120">
                    <template slot-scope="obj">{{ obj.row.addDate | formatDate }}</template>
                  </el-table-column>
                  <el-table-column prop="difficulty" label="难度">
                    <template slot-scope="scope">
                      <span v-if="scope.row.difficulty === '1'">一般</span>
                      <span v-else-if="scope.row.difficulty === '2'">简单</span>
                      <span v-else>困难</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="creator" label="录入人" width="120"></el-table-column>
                  <el-table-column prop="chkState" label="审核状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.chkState === 1">已通过</span>
                      <span v-else-if="scope.row.chkState === 2">已拒绝</span>
                      <span v-else>待审核</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="chkRemarks" label="审核意见" width="120"></el-table-column>
                  <el-table-column prop="chkUser" label="审核人"></el-table-column>
                  <el-table-column prop="publishState" label="发布状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.publishState === 1">已发布</span>
                      <span v-else-if="scope.row.publishState === 0">已下架</span>
                      <span v-else>待发布</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="right" label="操作" fixed="right" width="220">
                    <template #default="{row}">
                      <el-button type="text" size="samll" @click="seeChoice(row.id)">预览</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.chkState === 1"
                        @click="CheckChkState(row)"
                      >审核</el-button>
                      <el-button type="text" size="samll" :disabled="row.publishState === 1">修改</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        @click="open(row.id,row.publishState)"
                      >{{ row.publishState === 1? '下架':'上架' }}</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.publishState === 1"
                        @click="delopen(row.id)"
                      >删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
                <!-- 分页 -->
                <el-row type="flex" justify="end" class="pagination">
                  <!-- page-size每页显示条目个数 -->
                  <!-- current-page当前页码  @current-change监听分页-->
                  <el-pagination
                    background
                    :page-size="page.pagesize"
                    :page-sizes="[5, 10, 15]"
                    :current-page="page.page"
                    layout="prev, pager, next,sizes, jumper"
                    :total="total"
                    @current-change="pageChange"
                    @size-change="handleSizeChange"
                  />
                </el-row>
                <!-- 待审核结束 -->
              </el-tab-pane>
              <el-tab-pane label="已审核" name="third">
                <!-- 已审核开始 -->
                <el-row>
                  <template #default>
                    <el-alert slot="before" type="info" show-icon :closable="false">数据一共{{ total }}条</el-alert>
                  </template>
                </el-row>
                <el-table :data="list" style="width: 100%" height="250">
                  <el-table-column prop="number" label="试题编号" width="150"></el-table-column>
                  <el-table-column prop="subject" label="学科" width="120"></el-table-column>
                  <el-table-column prop="catalog" label="目录" width="120"></el-table-column>
                  <el-table-column prop="questionType" label="题型" width="120">
                    <template slot-scope="scope">
                      <span v-if="scope.row.difficulty === '1'">单选</span>
                      <span v-else-if="scope.row.difficulty === '2'">多选</span>
                      <span v-else>简答</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="question" label="题干" width="300">
                    <template v-slot="{row}">
                      <span v-html="row.question"></span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="addDate" label="录入时间" width="120">
                    <template slot-scope="obj">{{ obj.row.addDate | formatDate }}</template>
                  </el-table-column>
                  <el-table-column prop="difficulty" label="难度">
                    <template slot-scope="scope">
                      <span v-if="scope.row.difficulty === '1'">一般</span>
                      <span v-else-if="scope.row.difficulty === '2'">简单</span>
                      <span v-else>困难</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="creator" label="录入人" width="120"></el-table-column>
                  <el-table-column prop="chkState" label="审核状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.chkState === 1">已通过</span>
                      <span v-else-if="scope.row.chkState === 2">已拒绝</span>
                      <span v-else>待审核</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="chkRemarks" label="审核意见" width="120"></el-table-column>
                  <el-table-column prop="chkUser" label="审核人"></el-table-column>
                  <el-table-column prop="publishState" label="发布状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.publishState === 1">已发布</span>
                      <span v-else-if="scope.row.publishState === 0">已下架</span>
                      <span v-else>待发布</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="right" label="操作" fixed="right" width="220">
                    <template #default="{row}">
                      <el-button type="text" size="samll" @click="seeChoice(row.id)">预览</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.chkState === 1"
                        @click="CheckChkState(row)"
                      >审核</el-button>
                      <el-button type="text" size="samll" :disabled="row.publishState === 1">修改</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        @click="open(row.id,row.publishState)"
                      >{{ row.publishState === 1? '下架':'上架' }}</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.publishState === 1"
                        @click="delopen(row.id)"
                      >删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
                <!-- 已审核结束 -->
              </el-tab-pane>
              <el-tab-pane label="已拒绝" name="fourth">
                <!-- 已拒绝开始 -->
                <el-row>
                  <template #default>
                    <el-alert slot="before" type="info" show-icon :closable="false">数据一共{{ total }}条</el-alert>
                  </template>
                </el-row>
                <el-table :data="list" style="width: 100%" height="250">
                  <el-table-column prop="number" label="试题编号" width="150"></el-table-column>
                  <el-table-column prop="subject" label="学科" width="120"></el-table-column>
                  <el-table-column prop="catalog" label="目录" width="120"></el-table-column>
                  <el-table-column prop="questionType" label="题型" width="120">
                    <template slot-scope="scope">
                      <span v-if="scope.row.difficulty === '1'">单选</span>
                      <span v-else-if="scope.row.difficulty === '2'">多选</span>
                      <span v-else>简答</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="question" label="题干" width="300">
                    <template v-slot="{row}">
                      <span v-html="row.question"></span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="addDate" label="录入时间" width="120">
                    <template slot-scope="obj">{{ obj.row.addDate | formatDate }}</template>
                  </el-table-column>
                  <el-table-column prop="difficulty" label="难度">
                    <template slot-scope="scope">
                      <span v-if="scope.row.difficulty === '1'">一般</span>
                      <span v-else-if="scope.row.difficulty === '2'">简单</span>
                      <span v-else>困难</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="creator" label="录入人" width="120"></el-table-column>
                  <el-table-column prop="chkState" label="审核状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.chkState === 1">已通过</span>
                      <span v-else-if="scope.row.chkState === 2">已拒绝</span>
                      <span v-else>待审核</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="chkRemarks" label="审核意见" width="120"></el-table-column>
                  <el-table-column prop="chkUser" label="审核人"></el-table-column>
                  <el-table-column prop="publishState" label="发布状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.publishState === 1">已发布</span>
                      <span v-else-if="scope.row.publishState === 0">已下架</span>
                      <span v-else>待发布</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="right" label="操作" fixed="right" width="220">
                    <template #default="{row}">
                      <el-button type="text" size="samll" @click="seeChoice(row.id)">预览</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.chkState === 1"
                        @click="CheckChkState(row)"
                      >审核</el-button>
                      <el-button type="text" size="samll" :disabled="row.publishState === 1">修改</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        @click="open(row.id,row.publishState)"
                      >{{ row.publishState === 1? '下架':'上架' }}</el-button>
                      <el-button
                        type="text"
                        size="samll"
                        :disabled="row.publishState === 1"
                        @click="delopen(row.id)"
                      >删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
                <!-- 分页 -->
                <el-row type="flex" justify="end" class="pagination">
                  <!-- page-size每页显示条目个数 -->
                  <!-- current-page当前页码  @current-change监听分页-->
                  <el-pagination
                    background
                    :page-size="page.pagesize"
                    :page-sizes="[5, 10, 15]"
                    :current-page="page.page"
                    layout="prev, pager, next,sizes, jumper"
                    :total="total"
                    @current-change="pageChange"
                    @size-change="handleSizeChange"
                  />
                </el-row>
                <!-- 已拒绝结束 -->
              </el-tab-pane>
            </el-tabs>
            <!-- 全部结束 -->
          </el-row>
        </el-card>
        <!-- 预览 -->
        <see-choice v-if="showDialog" :show-dialog.sync="showDialog" :user="userId"/>
        <!-- 审核弹框 -->
        <el-dialog :visible="showvisible" title="题目审核" @close="btnCancel()">
          <el-form ref="Refform" :model="formDatas" :rules="rules">
            <el-row>
              <el-radio-group v-model="formDatas.chkState">
                <el-radio :label="1">通过</el-radio>
                <el-radio :label="2">拒绝</el-radio>
              </el-radio-group>
            </el-row>
            <el-row>
              <el-input
                v-model="formDatas.chkRemarks"
                type="textarea"
                style="margin-top:20px;width:150x;"
              ></el-input>
            </el-row>
            <el-row type="flex" justify="center" style="margin-top:20px;">
              <el-col :span="6">
                <el-button size="small" @click="btnCancel()">取消</el-button>
                <el-button size="small" type="primary" @click="btnOK()">确认</el-button>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
        <!-- 确认上下架题目 -->
      </div>
    </div>
  </div>
</template>

<script>
import { provinces, citys } from '@/assets/citys'
import SeeChoice from './components/see-choice'
import { getChoiceList, delChoice, CheckChkState } from '@/api/choice'
import { subjectlistTwo, subjectList, choiceState, getDirectList } from '@/api/subjects.js'
export default {
  name: 'Choice',
  components: {
    SeeChoice
    // ListChoice
  },
  data() {
    return {
      directListTwo: [],
      question: '',
      activeName: 'first',
      rules: {},
      Province: '',
      City: '',
      Subject: '',
      // 城市
      provinceAll: [],
      cityAll: [],
      ShortName: '',
      Remarks: '',
      keyword: '',
      creatorID: null,
      QuestionType: null,
      Difficulty: null,
      Direction: null,
      // 二级列表
      listsTwo: [],
      // 学科
      lists: [],
      // 上下架
      PSdialog: false,
      currentDataType: '0',
      // 列表
      list: [],
      page: {
        page: 1,
        pagesize: 5
      },
      formData: {
        city: null,
        province: null,
        twoLevelDirectory: null,
        keyword: null,
        id: null, // 编号
        subject: null, // 学科
        catalog: null, // 目录
        number: null, // 试题编号
        subjectID: null, // 学科
        catalogID: null, // 目录
        questionType: null, // 题型
        question: null, // 题干
        addDate: null, // 录入时间
        difficulty: null, // 难度
        creator: null, // 录入人
        chkState: null, // 审核状态
        chkRemarks: null, // 审核意见
        chkUser: null, // 审核人
        publishState: null, // 发布状态
        enterpriseID: null,
        remarks: null
      },
      total: 0,
      // 弹框
      showDialog: false,
      userId: null,
      showvisible: false, // 审核弹框
      formDatas: { id: null, chkState: 1, chkRemarks: '' }
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getChoiceList()
    this.subjectList()
    // this.subjectlist()
    this.provinceAll = provinces()
  },
  mounted() {},
  methods: {
    // 城市
    renderCity() {
      this.cityAll = citys(this.Province)
    },
    // 切换
    async handleClick({ name }) {
      const { data } = await getChoiceList(this.page)
      if (name === 'first') {
        this.list = data.items
        this.total = data.counts
      } else if (name === 'second') {
        this.list = data.items.filter(item => item.chkState === 0)
        this.total = this.list.length
      } else if (name === 'third') {
        this.list = data.items.filter(item => item.chkState === 1)
        this.total = this.list.length
      } else {
        this.list = data.items.filter(item => item.chkState === 2)
        this.total = this.list.length
      }
    },
    // 列表
    async getChoiceList() {
      const { data } = await getChoiceList()
      this.list = data.items
      // console.log(data)
      this.total = data.items.length
      // console.log(data)
    },
    //  newPage最新页码
    pageChange(newPage) {
      this.page.page = newPage
      this.getChoiceList() // 获取数据
    },
    // 监听了pagesize事件
    handleSizeChange(newSize) {
      this.page.pagesize = newSize
      this.getChoiceList()
    },
    // 预览
    seeChoice(id) {
      this.showDialog = true
      this.userId = id
    },
    //  审核
    CheckChkState(row) {
      this.showvisible = true
      // console.log(row)
      this.formDatas.id = row.id
      // this.getChoiceList()
    },
    // 确定审核
    async btnOK() {
      await CheckChkState(this.formDatas)
      this.getChoiceList()
      this.showvisible = false
      this.$message.success('操作成功')
    },
    // 关闭
    btnCancel() {
      this.$refs.Refform.resetFields()
      this.formDatas = { id: null, chkState: 1, chkRemarks: null }
      this.showvisible = false
    },
    // 确认上下架
    open(id, publishState) {
      this.$confirm('您确认下架这道题目吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        if (publishState === 1) {
          publishState = 0
        } else {
          publishState = 1
        }
        this.list = await choiceState(id, publishState)
        this.getChoiceList()
        this.$message({
          type: 'success',
          message: '上架成功!'
        })
      })
    },
    // 删除
    delopen(id) {
      this.$confirm('您确认删除这道题目吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        this.list = await delChoice(id)
        this.getChoiceList()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      })
    },
    // 获取学科列表
    async subjectList() {
      const { data } = await subjectList()
      this.lists = data
    },
    async selectChange(id) {
      const { data } = await subjectlistTwo(id)
      const res = await getDirectList(id)
      this.directListTwo = res.data
      this.listsTwo = data
      console.log(this.listsTwo)
    },
    // 搜索
    async newlist() {
      // const { data } = await getChoiceList({
      //   subjectID: this.formData.subjectID,
      //   keyword: this.formData.keyword,
      //   ...this.page
      // })
      const { data } = await getChoiceList({
        subjectID: this.formData.subjectID,
        keyword: this.formData.keyword,
        catalogID: this.formData.twoLevelDirectory,
        tags: this.formData.tags,
        questionType: this.QuestionType,
        difficulty: this.Difficulty,
        direction: this.Direction,
        creatorID: this.creatorID,
        remarks: this.Remarks,
        shortName: this.ShortName,
        province: this.Province,
        city: this.City,
        ...this.page
      })
      this.list = data.items
      this.total = data.items.length
    },
    // 清除
    clearAll() {
      this.formData = {
        subjectID: '',
        keyword: ''
      }
    }
  }
}
</script>
<style lang='scss' scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
